﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;

namespace ChouteZemUp.GameEntities
{
	public class Target: Engine.ControllerGameObject
	{
		protected int mPoint;

        public int Points { get { return mPoint; } }

		public static List<Target> sTargetList = new List<Target>();

		protected List<Bullet> mBulletList;

        public Target(Vector2 pPositionInitiale)
            : base(new Vector2(0, 1), 2.0f, "Target", pPositionInitiale, sContent, sGame)
        {
            mRenderedRect = new Rectangle(0, 0, 128, 128);
            AddAnimation("idle", "Target", 1.0f, 3);

            mPoint = 10;

            mBulletList = new List<Bullet>();

            sTargetList.Add(this);

            Play("idle");
        }

        public override void Update(GameTime pTime)
        {
            foreach (Bullet bullet in mBulletList)
            {
                if (this.Intersect(bullet) != null)
                {
                    this.Game.Components.Remove(this);
                }
                //TODO ajouter score
            }

            base.Update(pTime);
        }

        public void Destroy()
        {
            Game.Components.Remove(this);
        }
	}
}
